package design.prototype;

/**
 * \* User: Administrator
 * <p>
 * \* Date: 2020/9/22
 * <p>
 * \* Time: 9:32
 * <p>
 * \* Description: 不通过new关键字来产生一个对象，而是通过对象赋值来实现的模式叫   原型模式
 * \
 */
public class Client {
    private static int MAX = 6;
    public static void main(String[] args) throws CloneNotSupportedException {
        int i = 0;
        Mail mail = new Mail(new AdvTemplate());
        mail.setTail("XX银行版权所有");
        while(i < MAX) {
            Mail cloneMail = mail.clone();

            cloneMail.setAppellation(i + "先生（女士）");
            cloneMail.setReceiver(i + "@.com");
            sendMail(cloneMail);
            i ++;
        }
    }

    public static void sendMail(Mail mail) {
        System.out.println(mail.getSubject() + mail.getReceiver() + "发送成功");
    }
}
